home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / ldb / search.c < prev    next >
C/C++ Source or Header  |  1991-11-06  |  1KB  |  46 lines

  1.  
  2. #include "lisp.h"
  3. #include "ldb.h"
  4.  
  5. boolean search_for_type(type, start, count)
  6. int type;
  7. lispobj **start;
  8. int *count;
  9. {
  10.     lispobj obj, *addr;
  11.  
  12.     while ((*count == -1 || (*count > 0)) && valid_addr(*start)) {
  13.         obj = **start;
  14.         addr = *start;
  15.         if (*count != -1)
  16.             *count -= 2;
  17.  
  18.         if (TypeOf(obj) == type)
  19.             return TRUE;
  20.  
  21.         (*start) += 2;
  22.     }
  23.     return FALSE;
  24. }
  25.  
  26.  
  27. boolean search_for_symbol(name, start, count)
  28. char *name;
  29. lispobj **start;
  30. int *count;
  31. {
  32.     struct symbol *symbol;
  33.     struct vector *symbol_name;
  34.  
  35.     while (search_for_type(type_SymbolHeader, start, count)) {
  36.         symbol = (struct symbol *)PTR((lispobj)*start);
  37.     if (LowtagOf(symbol->name) == type_OtherPointer) {
  38.             symbol_name = (struct vector *)PTR(symbol->name);
  39.             if (valid_addr(symbol_name) && TypeOf(symbol_name->header) == type_SimpleString && strcmp((char *)symbol_name->data, name) == 0)
  40.                 return TRUE;
  41.     }
  42.         (*start) += 2;
  43.     }
  44.     return FALSE;
  45. }
  46.